function strToDate(dateStr){
	if(dateStr == null || dateStr == ''){
		return null;
	}else{
		dateStr = dateStr.replace(/-/g,"/");
		var date = new Date(dateStr);
		return date;
	}
}

function getFormatTime(date){
	if(date == null){
		return "";
	}
	var result = Math.abs(date.getTime()-new Date().getTime())
	if(result < 60000){// 一分钟内
		var seconds = Math.floor(result / 1000);
		r = seconds + "秒钟前";
	}else if (result >= 60000 && result < 3600000){// 一小时内
		var seconds = Math.floor(result / 60000);
		r = seconds + "分钟前";
	}else if (result >= 3600000 && result < 86400000){// 一天内
		var seconds = Math.floor(result / 3600000);
		r = seconds + "小时前";
	}else{
		r = date.Format("yyyy-MM-dd") ;
	}
	return r;
}

Date.prototype.Format = function(fmt)   
{ //author: meizz   
  var o = {   
    "M+" : this.getMonth()+1,                 //月份   
    "d+" : this.getDate(),                    //日   
    "h+" : this.getHours(),                   //小时   
    "m+" : this.getMinutes(),                 //分   
    "s+" : this.getSeconds(),                 //秒   
    "q+" : Math.floor((this.getMonth()+3)/3), //季度   
    "S"  : this.getMilliseconds()             //毫秒   
  };   
  if(/(y+)/.test(fmt))   
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
  for(var k in o)   
    if(new RegExp("("+ k +")").test(fmt))   
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
  return fmt;   
} 

function GetRandomNum(Min,Max)
{   
	var Range = Max - Min;   
	var Rand = Math.random();   
	return(Min + Math.round(Rand * Range));   
}

var GetLength = function (str) {
    ///<summary>获得字符串实际长度，中文2，英文1</summary>
    ///<param name="str">要获得长度的字符串</param>
    var realLength = 0, len = str.length, charCode = -1;
    for (var i = 0; i < len; i++) {
        charCode = str.charCodeAt(i);
        if (charCode >= 0 && charCode <= 128) realLength += 1;
        else realLength += 2;
    }
    return realLength;
}

function cutstr(str, len) {
    var str_length = 0;
    var str_len = 0;
    str_cut = new String();
    str_len = str.length;
    for (var i = 0; i < str_len; i++) {
        a = str.charAt(i);
        str_length++;
        if (escape(a).length > 4) {
            //中文字符的长度经编码之后大于4  
            str_length++;
        }
        str_cut = str_cut.concat(a);
        if (str_length >= len) {
            str_cut = str_cut.concat("...");
            return str_cut;
        }
    }
    //如果给定字符串小于指定长度，则返回源字符串；  
    if (str_length < len) {
        return str;
    }
}


function isValid(s,def){
	if(undefined == s || null == s || "null" == s || s == ""){
		return def;
	}else{
		return s;
	}	
}

function Fen2Yuan(num) {
	  if ( typeof num !== "number" || isNaN(num) || num === 0) return 0;
	  return ( num / 100 ).toFixed( 2 );
}

var browser={
       versions:function() {
            var u=navigator.userAgent, app = navigator.appVersion;
            return {//移动终端浏览器版本信息
                trident: u.indexOf('Trident') > -1, //IE内核
                presto: u.indexOf('Presto') > -1, //opera内核
                webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端
                ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
                iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
                iPad: u.indexOf('iPad') > -1, //是否iPad
                webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部
            };
      }(),
      language:(navigator.browserLanguage || navigator.language).toLowerCase()
 }

var fakeNum = 0;
var actNum = 0;
function getFakeNum(showTime){
	var nn = new Date().getTime()-showTime;
	var mm = Math.round((nn / (1000 * 60)));
	if(mm >= 0 && mm < 10){
		fakeNum = 16;
	}else if(mm >= 10 && mm < 15){
		fakeNum = 123;
	}else if(mm >= 15 && mm < 25){
		fakeNum = 234;
	}else if(mm >= 25 && mm < 45){
		fakeNum = 345;
	}else if(mm >= 45 && mm < 60){
		fakeNum = 432;
	}else if(mm >= 60){
		fakeNum = 488;
	}
	return fakeNum;
}